#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main() {
	int other = 0, digit = 0, lower = 0, upper = 0;
	char ch, coverch;
	FILE *fread, *fcopy;
	char buffer[1024] = {0};
	fread = fopen("read.txt", "r");
	fcopy = fopen("copy.txt", "w");
	if(fread == NULL || fcopy == NULL){
		perror("fopen");
		exit(1);
	}else{
		printf("open success\n");
	}
	while((ch = fgetc(fread)) != EOF){
		if(islower(ch)){
			coverch = toupper(ch);
		}else if(isupper(ch)){
			coverch = tolower(ch);
		}else{
			coverch = ch;
		}
		fputc(coverch, fcopy);
		if(isdigit(ch)){
			digit++;
		}else if(islower(ch)){
			lower++;
		}else if(isupper(ch)){
			upper++;
		}else{
			other++;
		}
	}

	printf("数字个数: %d\n", digit);
	printf("小写字母个数: %d\n", lower);
	printf("大写字母个数: %d\n", upper);
	printf("其他字符个数: %d\n", other);
	fclose(fread);
	fclose(fcopy);
	return 0;
}
